import apiRequest from '../utils/apiRequest'

// 获取采购订单列表
export const getPurchaseOrders = (params) => {
  return apiRequest.get('/api/PurchaseOrders', { params })
}

// 获取采购订单详情
export const getPurchaseOrderById = (id) => {
  return apiRequest.get(`/api/PurchaseOrders/${id}`)
}

// 创建采购订单
export const createPurchaseOrder = (data) => {
  return apiRequest.post('/api/PurchaseOrders', data)
}

// 更新采购订单
export const updatePurchaseOrder = (id, data) => {
  return apiRequest.put(`/api/PurchaseOrders/${id}`, data)
}

// 删除采购订单
export const deletePurchaseOrder = (id) => {
  return apiRequest.delete(`/api/PurchaseOrders/${id}`)
}

// 审核采购订单
export const reviewPurchaseOrder = (id, reviewedBy, isApproved, comments) => {
  return apiRequest.put(`/api/PurchaseOrders/${id}/review`, {
    ReviewedBy: reviewedBy,
    IsApproved: isApproved,
    Comments: comments
  })
}

// 关闭采购订单
export const closePurchaseOrder = (id, closedBy, reason) => {
  return apiRequest.put(`/api/PurchaseOrders/${id}/close`, {
    ClosedBy: closedBy,
    Reason: reason
  })
}